package com.example.zookeeper1.config;


import org.apache.zookeeper.ZooKeeper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class zkconfig {

    @Value("${zookeeper.server}")
    private String server;

    @Value("${zookeeper.timeout}")
    private Integer timeout;

    @Bean
    public ZooKeeper zooKeeper() throws IOException {
        return new ZooKeeper(server,timeout,watchedEvent -> {
            System.out.println("===监听变化===");
            System.out.println(watchedEvent);
//            watchedEvent.
        });
    }
}
